<template>
  <!-- 量表结果 -->
  <section>
    <el-tabs v-if="tableList.length >0" v-model="tabName" type="border-card">
      <template v-for="(item,index) in tableList">
        <el-tab-pane :key="index" :name="'t'+index">
          <template v-slot:label>
            <div class="title-report overflow-omit">{{item.scaleName}}</div>
          </template>
          <lbResultDetail :dataItem="item" :patientId="patientId" :patientInfo="patientInfo"></lbResultDetail>
        </el-tab-pane>
      </template>
    </el-tabs>
    <div v-if="tableList.length == 0" style="color:#999;padding:10px 0;text-align:center;">
      <i class="iconfont iconwushuju" style="font-size:40px;"></i>
      <div>暂无数据</div>
    </div>
  </section>
</template>
<script>
export default {
  props: ["patientId"],
  components: {
    lbResultDetail: () => import("./lbResultDetail.vue")
  },
  data() {
    return {
      tabName: "t0",
      tableList: [],
      patientInfo: null
    };
  },
  mounted() {
    const th = this;
    th.getData();
    th.getUser();
  },
  methods: {
    getUser() {
      const th = this;
      let j = {
        patientId: th.patientId,
        hpId: th.adminUser.hpId
      };
      th.$api.getThePatientLibraryById(j).then(res => {
        if (res.executed) {
          th.patientInfo = res.thePatientLibraryDetail;
        }
      });
    },
    getData() {
      const th = this;
      let j = {
        patientId: th.patientId,
        pageNum: 1,
        pageSize: 100
      };
      th.$api.findScaleDetailByPatientId(j).then(res => {
        if (res.executed) {
          th.tableList = res.dataBody.list;
        }
      });
    }
  }
};
</script>